// pages/user/user.js
Page({

  /**
   * Page initial data
   */
  data: {
    name:"姓名",
    sex:"性别",
    age:"年龄",
    showModalStatus: false
  },

  /**
   * Lifecycle function--Called when page load
   */
  onLoad: function (options) {
    if (wx.getStorageSync("name")){
      let temp1 = wx.getStorageSync("name");
      let temp2 = wx.getStorageSync("sex");
      let temp3 = wx.getStorageSync("age");
      this.setData({
        name: temp1,
        sex: temp2,
        age: temp3,
      })
    }
    
  },
  /**
   * 动画
   */
  powerDrawer: function (e) {
    var currentStatu = e.currentTarget.dataset.statu;
    this.util(currentStatu)
    let index = e.currentTarget.id
  },
  util: function (currentStatu) {
    var animation = wx.createAnimation({
      duration: 200,  //动画时长
      timingFunction: "linear", //线性
      delay: 0  //0则不延迟
    });

    this.animation = animation;
    animation.opacity(0).rotateX(-100).step();
    this.setData({
      animationData: animation.export()
    })

    setTimeout(function () {
      animation.opacity(1).rotateX(0).step();
      this.setData({
        animationData: animation
      })

      if (currentStatu == "close") {
        this.setData({
          showModalStatus: false
        });
      }
    }.bind(this), 200)
    if (currentStatu == "open") {
      this.setData({
        showModalStatus: true
      });
    }
  },
  nameinput:function(e){
    this.setData({
      name:e.detail.value
    })
    wx.setStorage({
      key: 'name',
      data: e.detail.value,
    })
  },
  sexinput: function (e) {
    this.setData({
      sex: e.detail.value
    })
    wx.setStorage({
      key: 'sex',
      data: e.detail.value,
    })
  },
  ageinput: function (e) {
    this.setData({
      age: e.detail.value
    })
    wx.setStorage({
      key: 'age',
      data: e.detail.value,
    })
  },
})